package com.qf.controller;

import com.qf.entity.Friend;
import com.qf.entity.base.ResultEntity;
import com.qf.service.IFriendService;
import com.qf.service.api.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description:
 * @Author: xbb
 * @Date:2020/4/15
 */
@RestController
@RequestMapping("/friend")
public class FriendController {

    @Autowired
    private IFriendService friendService;

    @Autowired
    private IUserService userService;

    @RequestMapping("/getFriendListById")
        public ResultEntity getFriendListById(Integer uid){
        System.out.println("uid = " + uid);
        List<Friend> friendList = friendService.getFriendListById(uid);
        for (Friend friend:friendList){
            friend.setFriendObj(userService.getUserById(friend.getFid()));
        }
        friendList.forEach(System.out::println);
        return ResultEntity.successs(friendList);
    }
}
